//
//  MJPhotoToolbar.m
//  FingerNews
//
//  Created by mj on 13-9-24.
//  Copyright (c) 2013年 itcast. All rights reserved.
//

#import "MJPhotoToolbar.h"
#import "MJPhoto.h"
//#import "MBProgressHUD+Add.h"

#define BWITH 80 //分享等按钮宽度
#define BHEIGHT 40//分享等按钮高度

@interface MJPhotoToolbar()
{

}
@end

@implementation MJPhotoToolbar

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }

    return self;
}

- (void)sharePhoto{
    NSLog(@"share photo");
    
    [self.delegate shareCurrentImage];
}

-(void)saveImageToMyLib{
    [self.delegate saveImageToMyLibrary];
}


-(void)saveImageToMyPhoneLib{
    [self.delegate saveImageToMyPhoneLibrary];
}

-(void)deletePhoto{
    [self.delegate deleteCurrentImage];
}


- (void)setPhotos:(NSArray *)photos
{
    _photos = photos;
    
    
    /*
    if (_photos.count > 1) {
        _indexLabel = [[UILabel alloc] init];
        _indexLabel.font = [UIFont boldSystemFontOfSize:20];
        _indexLabel.frame = CGRectMake(0, 50, 320, 44);
        _indexLabel.backgroundColor = [UIColor clearColor];
        _indexLabel.textColor = [UIColor whiteColor];
        _indexLabel.textAlignment = NSTextAlignmentCenter;
        _indexLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        [self addSubview:_indexLabel];
    }
    */
    
    /*
    // 保存图片按钮
    CGFloat btnWidth = 44;
    _saveImageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _saveImageBtn.frame = CGRectMake(20, 50, btnWidth, btnWidth);
    _saveImageBtn.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    [_saveImageBtn setImage:[UIImage imageNamed:@"MJPhotoBrowser.bundle/save_icon.png"] forState:UIControlStateNormal];
    [_saveImageBtn setImage:[UIImage imageNamed:@"MJPhotoBrowser.bundle/save_icon_highlighted.png"] forState:UIControlStateHighlighted];
    [_saveImageBtn addTarget:self action:@selector(saveImage) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_saveImageBtn];
    */
 
}



/*
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    if (error) {
        //        [MBProgressHUD showSuccess:@"保存失败" toView:nil];
        NSLog(@"保存失败");
        
    } else {
        MJPhoto *photo = _photos[_currentPhotoIndex];
        photo.save = YES;
//        _saveImageBtn.enabled = NO;
        NSLog(@"成功保存");
        
        //        [MBProgressHUD showSuccess:@"成功保存到相册" toView:nil];
    }
}
*/
 
- (void)setCurrentPhotoIndex:(NSUInteger)currentPhotoIndex
{
//    _currentPhotoIndex = currentPhotoIndex;
//    
//    // 更新页码
//    _indexLabel.text = [NSString stringWithFormat:@"%lu / %lu", _currentPhotoIndex + 1, (unsigned long)_photos.count];
//    
//    MJPhoto *photo = _photos[_currentPhotoIndex];
//    [_textView setText:photo.photoDescription];
    // 按钮
//    _saveImageBtn.enabled = photo.image != nil && !photo.save;
}

@end
